<template>
  <view class="uni-container">
    <uni-table ref="table" border stripe emptyText="暂无更多数据">
      <uni-tr>
        <uni-th align="center">组织</uni-th>
        <uni-th width="80" align="center">当前周期</uni-th>
        <uni-th width="80" align="center">上一周期</uni-th>
      </uni-tr>
      <uni-tr v-for="(item, index) in shopdata.sort((a, b) => Number(b.count) - Number(a.count))" :key="index">
        <uni-td>
          <uv-text type="primary" :text="item.name" @click="() => click(item)">
          </uv-text>
        </uni-td>
        <uni-td>
          <view class="name">{{ item.count }}</view>
        </uni-td>
        <uni-td>{{ item.Ocount }}</uni-td>
      </uni-tr>
    </uni-table>
  </view>
</template>

<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";

interface Idata {
  dept_id: string;
  name: string;
  count: string;
  aiidentifylabelid: string;
  release: string;
  Ocount: string;
  identifylabelid: string;
}
const shopdata = ref<Idata[]>([]);
const identifylabelid = ref<string>("");
const aiidentifylabelid = ref<string>("");
const productid = ref('')

function click(data: Idata) {
  let url = `/pages/comment/listindex?dep_id=${data.dept_id}&starttime=${starttime.value}&endtime=${endtime.value}`;
  if (identifylabelid.value) {
    url += `&identifylabelid=${identifylabelid.value}`;
  }
  if (aiidentifylabelid.value) {
    url += `&aiidentifylabelid=${aiidentifylabelid.value}`;
  }
  if(productid.value) {
    url += `&productid=${productid.value}`;
  }
  console.log(url);
  uni.navigateTo({
    url,
  });
}
const starttime = ref();
const endtime = ref();
onLoad((options) => {
  shopdata.value = JSON.parse(uni.getStorageSync("shopdata"));
  starttime.value = options?.starttime;
  endtime.value = options?.endtime;
  identifylabelid.value = options?.identifylabelid;
  aiidentifylabelid.value = options?.aiidentifylabelid;
  productid.value = options?.productid;
});
</script>

<style lang="scss"></style>
